home *** CD-ROM | disk | FTP | other *** search
/ isnet Internet / Isnet Internet CD.iso / prog / hiz / 09 / 09.exe / adynware.exe / perl / lib / site / DBI / FAQ.pm < prev    next >
Encoding:
Perl POD Document  |  1999-12-28  |  30.9 KB  |  856 lines

  1.  
  2. package DBI::FAQ;
  3.  
  4. =head1 NAME
  5.  
  6. DBI::FAQ -- The Frequently Asked Questions for the Perl5 Database Interface
  7.  
  8. =for html
  9. <HTML>
  10. <HEAD>
  11. <!-- -->
  12. <!-- $Id: FAQ.pm,v 1.5 1997/07/15 10:58:27 timbo Exp $ -->
  13. <!-- -->
  14. <TITLE>Frequently Asked Questions for DBI</TITLE>
  15. </HEAD>
  16. <BODY BGCOLOR="#ffffff" TEXT="#000000" LINK="#3a15ff" ALINK="#ff0000" VLINK="#ff282d">
  17. <CENTER>
  18. <IMG SRC="/img/hermlogo.gif" WIDTH=437 HEIGHT=115 ALT="[ Hermetica ]">
  19. </CENTER>
  20. <HR>
  21. <P>
  22. <CENTER>
  23. <FONT SIZE="+2">
  24. DBI Frequently Asked Questions v.0.35
  25. </FONT>
  26. <BR>
  27. <FONT SIZE="-1">
  28. <I>Last updated: June 20th, 1997</I>
  29. </FONT>
  30. </CENTER>
  31. <P>
  32.  
  33. =head1 SYNOPSIS
  34.  
  35.     perldoc DBI::FAQ
  36.  
  37. =head1 VERSION
  38.  
  39. This document is currently at version I<0.35>, as of I<June 20th, 1997>.
  40.  
  41. =head1 DESCRIPTION
  42.  
  43. This document serves to answer the most frequently asked questions on both
  44. the DBI Mailing Lists and personally to members of the DBI development team.
  45.  
  46. =head1 Basic Information & Information Sources
  47.  
  48. =head2 1.1 What is DBI, DBperl, Oraperl and *perl?
  49.  
  50. To quote Tim Bunce, the architect and author of DBI:
  51.  
  52.     ``DBI is a database access Application Programming Interface (API)
  53.       for the Perl Language. The DBI API Specification defines a set
  54.       of functions, variables and conventions that provide a consistent
  55.       database interface independant of the actual database being used.''
  56.  
  57. In simple language, the DBI interface allows users to access multiple database
  58. types transparently. So, if you connecting to an Oracle, Informix, mSQL, Sybase
  59. or whatever database, you don't need to know the underlying mechanics of the
  60. interface. The API defined by DBI will work on I<all> these database types.
  61.  
  62. A similar benefit is gained by the ability to connect to two I<different>
  63. databases of different vendor within the one perl script, I<ie>, I want
  64. to read data from an Oracle database and insert it back into an Informix
  65. database all within one program. The DBI layer allows you to do this simply
  66. and powerfully.
  67.  
  68.  
  69. =for html
  70. Here's a diagram that demonstrates the principle:
  71. <P>
  72. <CENTER>
  73. <IMG SRC="img/dbiarch.gif" WIDTH=451 HEIGHT=321 ALT="[ DBI Architecture ]">
  74. </CENTER>
  75. <P>
  76.  
  77. I<DBperl> is the old name for the interface specification. It's usually
  78. now used to denote perlI<4> modules on database interfacing, such as,
  79. I<oraperl>, I<isqlperl>, I<ingperl> and so on. These interfaces
  80. didn't have a standard API and are generally I<not> supported.
  81.  
  82. Here's a list of old DBperl's, their corresponding DBI counterparts and
  83. support information. I<Please note>, the author's listed here generally
  84. I<do not> maintain the DBI module for the same database. These email
  85. addresses are unverified and should only be used for queries concerning the
  86. perl4 modules listed below. DBI driver queries should be directed to the
  87. I<dbi-users> mailing list.
  88.  
  89.   Perl4 Name  Database          Author                  DBI Driver
  90.   ----------  --------          ------                  ----------
  91.   Sybperl     Sybase            Michael Peppler         DBD::Sybase
  92.                                 <mpeppler@itf.ch>
  93.   Oraperl     Oracle 6 & 7      Kevin Stock             DBD::Oracle
  94.                                 <dbi-users@fugue.com>
  95.   Ingperl     Ingres            Tim Bunce &             DBD::Ingres
  96.                                 Ted Lemon
  97.                                 <dbi-users@fugue.com>
  98.   Interperl   Interbase         Buzz Moschetti          DBD::Interbase
  99.                                 <buzz@bear.com>
  100.   Uniperl     Unify 5.0         Rick Wargo              None
  101.                                 <rickers@coe.drexel.edu>
  102.   Pgperl      Postgres          Igor Metz               DBD::Pg
  103.                                 <metz@iam.unibe.ch>
  104.   Btreeperl   NDBM              John Conover            SDBM?
  105.                                 <john@johncon.com>
  106.   Ctreeperl   C-Tree            John Conover            None
  107.                                 <john@johncon.com>
  108.   Cisamperl   Informix C-ISAM   Mathias Koerber         None
  109.                                 <mathias@unicorn.swi.com.sg>
  110.   Duaperl     X.500 Directory   Eric Douglas            None
  111.               User Agent
  112.  
  113. However, some DBI modules have DBperl emulation layers, so, I<DBD::Oracle>
  114. for example comes with an Oraperl emulation layer, which allows you to
  115. run legacy oraperl scripts without modification. The emulation layer
  116. translates the oraperl API calls into the corresponding DBI calls.
  117.  
  118. Here's a table of emulation layer information:
  119.  
  120.     Module          Emulation Layer     Status
  121.     ------          ---------------     ------
  122.     DBD::Oracle     Oraperl             Complete
  123.     DBD::Ingres     Ingperl             Complete
  124.     DBD::Informix   Isqlperl            Under development
  125.     DBD::Sybase     Sybperl             Working? ( Needs verification )
  126.     DBD::mSQL       Msqlperl            Experimentally released with 
  127.                                         DBD::mSQL-0.61
  128.  
  129. The I<Msqlperl> emulation is a special case. I<Msqlperl> is a perl5 driver
  130. for I<mSQL> databases, but does not conform to the DBI Specification. It's
  131. use is being deprecated in favour of I<DBD::mSQL>. I<Msqlperl> may be downloaded
  132. from CPAN I<via>:
  133.  
  134.     http://www.perl.com/cgi-bin/cpan_mod?module=Msqlperl
  135.  
  136. =head2 1.2. Where can I get it from?
  137.  
  138. DBI is primarily distributed from:
  139.  
  140.     ftp://ftp.demon.co.uk/pub/perl/db
  141.  
  142. The Comprehensive Perl Archive Network resources should be used for
  143. retrieving up-to-date versions of the drivers.  Local CPAN sites may be
  144. accessed I<via> Tom Christiansen's splendid I<CPAN multiplexer> program
  145. located at:
  146.  
  147.     http://www.perl.com/CPAN/
  148.  
  149. For more specific version information and exact URLs of drivers, please see
  150. the DBI drivers list and the DBI module pages which can be found on:
  151.  
  152.     http://www.hermetica.com/technologia/perl/DBI
  153.  
  154. =head2 1.3. Where can I get more information?
  155.  
  156. There are a few information sources on DBI. 
  157.  
  158. =over 4
  159.  
  160. =item I<DBI Specification>
  161.  
  162.     http://www.hermetica.com/technologia/perl/DBI/doc/dbispec
  163.  
  164. There are two specifications available at this link, the new DBI Draft
  165. Specification which is a rapidly evolving document as Tim Bunce and the
  166. development team drive towards a stable interface, and the old
  167. historical DBperl Specification out of which the current DBI interface
  168. evolved.
  169.  
  170. The latter document should be regarded as being of historical interest 
  171. only and should not serve as a programming manual, or authoratative in any 
  172. sense. However, it is still a very useful reference source.
  173.  
  174. =item I<POD documentation>
  175.  
  176. I<POD>s are chunks of documentation usually embedded within perl programs
  177. that document the code ``I<in place>'', providing a useful resource for
  178. programmers and users of modules. POD for DBI and drivers is beginning to 
  179. become more commonplace, and documentation for these modules can be read
  180. with the following commands.
  181.  
  182. =over 4 
  183.  
  184. =item The DBI Specification
  185.  
  186. The POD for the DBI Specification can be read with the:
  187.  
  188.     perldoc DBI
  189.  
  190. command.
  191.  
  192. =item Frequently Asked Questions
  193.  
  194. This document, the I<Frequently Asked Questions> is also available as POD
  195. documentation! You can read this on your own system by typing:
  196.  
  197.     perldoc DBI::FAQ
  198.  
  199. This may be more convenient to persons not permanently, or conveniently,
  200. connected to the Internet but the document may not be the latest version.
  201.  
  202. =item Oraperl
  203.  
  204. Users of the Oraperl emulation layer bundled with I<DBD::Oracle>, may read
  205. up on how to program with the Oraperl interface by typing:
  206.  
  207.     perldoc Oraperl
  208.  
  209. This will produce an updated copy of the original oraperl man page written by
  210. Kevin Stock for perl4. The oraperl API is fully listed and described there.
  211.  
  212. =item DBD::mSQL
  213.  
  214. Users of the I<DBD::mSQL> module may read about some of the private functions
  215. and quirks of that driver by typing:
  216.  
  217.     perldoc DBD::mSQL
  218.  
  219. =item POD in general
  220.  
  221. Information on writing POD, and on the philosophy of POD in general, can be
  222. read by typing:
  223.  
  224.     perldoc perlpod
  225.  
  226. Users with the Tk module installed may be interested to learn there is a
  227. Tk-based POD reader available called C<tkpod>, which formats POD in a convenient
  228. and readable way.
  229.  
  230. =back
  231.  
  232. =item I<Rambles, Tidbits and Observations>
  233.  
  234.     http://www.hermetica.com/technologia/perl/DBI/tidbits
  235.  
  236. There are a series of occasional rambles from various people on the
  237. DBI mailing lists who, in an attempt to clear up a simple point, end up
  238. drafting fairly comprehensive documents. These are quite often varying in
  239. quality, but do provide some insights into the workings of the interfaces.
  240.  
  241. =item I<``DBI -- The perl5 Database Interface''>
  242.  
  243. This is an article written by Alligator Descartes and Tim Bunce on the
  244. structure of DBI. It was published in issue 5 of ``I<The Perl Journal>''. 
  245. It's I<extremely> good. Go buy the magazine. In fact, buy all of them! 
  246. ``The Perl Journal''s WWW site is:
  247.  
  248.     http://www.tpj.com
  249.  
  250. =item I<``DBperl''>
  251.  
  252. This article, published in the November 1996 edition of ``Dr. Dobbs
  253. Journal'' concerned I<DBperl>. The author of this edition apparently did
  254. not bother to contact any of the DBI development team members for verification
  255. of the information contained within his article. Several reviews of the
  256. article on the I<dbi-users> mailing list were disparaging, to say the least.
  257. The fact the article was written about I<DBperl> instead of I<DBI> hints
  258. at the staleness of the information.  However, we include the reference
  259. for completeness' sake.
  260.  
  261. =item I<``The Perl5 Database Interface''>
  262.  
  263. This item is a book to be written by Alligator Descartes ( for it is me )
  264. and published by O'Reilly and Associates this coming Winter. 
  265.  
  266. Here is the putative table of contents for the book.
  267.  
  268.      * Introduction
  269.           + Databases
  270.           + CGI / WWW
  271.           + perl
  272.      * Basic Database Concepts
  273.           + Types of Database
  274.                o Flat File
  275.                o AnyDBM
  276.                o RDBMS
  277.           + Using Which Database For What...
  278.      * SQL
  279.           + Why SQL?
  280.           + Structuring Information In Databases
  281.           + Retrieving Data From Databases
  282.           + Manipulating Data and Data Structures
  283.      * DBI Architecture
  284.      * Programming with DBI
  285.           + DBI Initialization
  286.           + Handles
  287.                o Driver Handles
  288.                o Database Handles
  289.                o Statement Handles
  290.           + Connection and Disconnection
  291.           + Handling Errors
  292.           + Issuing Simple Queries
  293.           + Executing Atomic Statements
  294.           + Statement MetaData
  295.           + More perl-ish Statements
  296.           + Binding
  297.           + Transaction Handling
  298.           + Utility Methods
  299.           + Handle Attributes and Dynamic Variables
  300.      * DBI and ODBC
  301.      * The Database Drivers
  302.           + DBD::Oracle and oraperl
  303.           + DBD::Informix and isqlperl
  304.           + DBD::mSQL and Msqlperl
  305.      * Case Studies
  306.           + DBI and the WWW
  307.           + Data Migration and Warehousing
  308.           + Administration Software
  309.      * Appendix: API Reference / Specification
  310.      * Appendix: Resources
  311.  
  312. =item I<README files>
  313.  
  314. The I<README> files included with each driver occasionally contains 
  315. some very useful information ( no, really! ) that may be pertinent to the user.
  316. Please read them. It makes our worthless existences more bearable. These
  317. can all be read from the main DBI WWW page at:
  318.  
  319.     http://www.hermetica.com/technologia/perl/DBI
  320.  
  321. =item I<Mailing Lists>
  322.  
  323. There are three mailing lists for DBI run by Ted Lemon. These can all
  324. be subscribed to and unsubscribed from I<via> the World Wide Web at the
  325. URL of:
  326.  
  327.     http://www.fugue.com/dbi
  328.  
  329. If you cannot successfully use the WWW form on the above page, please
  330. subscribe to the list in the following manner:
  331.  
  332.     Email: 'dbi-XXX-request@fugue.com' with a message body of
  333.     'subscribe'
  334.  
  335. Where 'dbi-XXX' is the name of the mailing list you are interested in.
  336. But note that your request will be handled by a human and may take some
  337. time.
  338.  
  339. The lists that users may participate in are:
  340.  
  341. =over 4
  342.  
  343. =item I<dbi-announce>
  344.  
  345. This mailing list is for announcements only. Very low traffic. The
  346. announcements are usually posted on the main DBI WWW page.
  347.  
  348. =item I<dbi-dev>
  349.  
  350. This mailing list is intended for the use of developers discussing
  351. ideas and concepts for the DBI interface, API and driver mechanics.
  352. Only any use for developers, or interested parties. Low traffic.
  353.  
  354. =item I<dbi-users>
  355.  
  356. This mailing list is a general discussion list used for bug reporting,
  357. problem discussion and general enquiries. Medium traffic.
  358.  
  359. =back
  360.  
  361. =item I<Mailing List Archives>
  362.  
  363. =over 4
  364.  
  365. =item I<US Mailing List Archives>
  366.  
  367.     http://outside.organic.com/mail-archives/dbi-users/
  368.  
  369. Searchable hypermail archives of the three mailing lists, and some of the
  370. much older traffic have been set up for users to browse.
  371.  
  372. =item I<European Mailing List Archives>
  373.  
  374.     http://www.rosat.mpe-garching.mpg.de/mailing-lists/PerlDB-Interest
  375.  
  376. As per the US archive above.
  377.  
  378. =back
  379.  
  380. =back
  381.  
  382. =head1 Compilation Problems
  383.  
  384. =head2 2.1. Compilation problems or "It fails the test!"
  385.  
  386. First off, consult the online information about the module, beit
  387. DBI itself, or a DBD, and see if it's a known compilation problem on your
  388. architecture. These documents can be found at:
  389.  
  390.     http://www.hermetica.com/technologia/perl/DBI
  391.  
  392. If it's a known problem, you'll probably have to wait till it gets fixed. If 
  393. you're I<really> needing it fixed, try the following:
  394.  
  395. =over 4
  396.  
  397. =item I<Attempt to fix it yourself>
  398.  
  399. This technique is generally I<not> recommended to the faint-hearted.
  400. If you do think you have managed to fix it, then, send a patch file
  401. ( context diff ) to the author with an explanation of:
  402.  
  403. =over 4
  404.  
  405. =item *
  406.  
  407. What the problem was, and test cases, if possible.
  408.  
  409. =item *
  410.  
  411. What you needed to do to fix it. Please make sure you mention everything.
  412.  
  413. =item *
  414.  
  415. Platform information, database version, perl version (C<perl -V>), module
  416. version and DBI version.
  417.  
  418. =back
  419.  
  420. =item I<Email the author> Do I<NOT> whinge!
  421.  
  422. Please email the address listed in the WWW pages for whichever driver you
  423. are having problems with. Do I<not> directly email the author at a
  424. known address unless it corresponds with the one listed. Some authors,
  425. including Tim Bunce, specifically do not want mail sent directly to them.
  426.  
  427. We tend to have real jobs to do, and we do read the mailing lists for
  428. problems. Besides, we may not have access to <I<insert your
  429. favourite brain-damaged platform here>> and couldn't be of any
  430. assistance anyway! Apologies for sounding harsh, but that's the way of it!
  431.  
  432. However, you might catch one of these creative genii at 3am when we're
  433. doing this sort of stuff anyway, and get a patch within 5 minutes. The
  434. atmosphere in the DBI circle is that we I<do> appreciate the users'
  435. problems, since we work in similar environments.
  436.  
  437. If you are planning to email the author, please furnish as much information
  438. as possible, I<ie>:
  439.  
  440. =over 4
  441.  
  442. =item *
  443.  
  444. I<ALL> the information asked for in the README file for
  445. the problematic module. And we mean I<ALL> of it. We don't
  446. put lines like that in documentation for the good of our health, or
  447. to meet obscure README file standards of length.
  448.  
  449. =item *
  450.  
  451. If you have a core dump, try the I<Devel::CoreStack> module for
  452. generating a stack trace from the core dump. Send us that too.
  453. I<Devel::CoreStack> can be found on CPAN at:
  454.  
  455.     http://www.perl.com/cgi-bin/cpan_mod?module=Devel::CoreStack
  456.  
  457. =item *
  458.  
  459. Module versions, perl version, test cases, operating system versions
  460. and I<any other pertinent information>.
  461.  
  462. =back
  463.  
  464. Remember, the more information you send us, the quicker we can track 
  465. problems down. If you send us no useful information, expect nothing back.
  466.  
  467. =item I<Email the dbi-users Mailing List>
  468.  
  469. It's usually a fairly intelligent idea to I<cc> the mailing list
  470. anyway with problems. The authors all read the lists, so you lose nothing
  471. by mailing there.
  472.  
  473. =back
  474.  
  475. =head1 Platform and Driver Issues
  476.  
  477. =head2 3.1 What's the difference between ODBC and DBI?
  478.  
  479. Good question! To be filled in more detail! Meanwhile see the notes at the
  480. end of the DBI README file.
  481.  
  482. =head2 3.2 Is DBI supported under Windows 95 / NT platforms?
  483.  
  484. Finally, yes! Jeff Urlwin has been working diligently on building
  485. I<DBI> and I<DBD::Oracle> under these platforms, and, with the
  486. advent of a stabler perl and a port of I<MakeMaker>, the project has
  487. come on by great leaps and bounds.
  488.  
  489. Recent I<DBI> and I<DBD::Oracle> modules will build and work out-of-the-box
  490. on Win32 with the standard perl 5.004 (or later) version of perl.
  491.  
  492. If you have to use the old non-standard ActiveWare perl port you can't use
  493. the standard DBI and DBD::Oracle modules out-of-the-box. Details of the 
  494. changes required and pre-patched versions can be found at:
  495.  
  496.     http://www.hermetica.com/technologia/perl/DBI/win32
  497.  
  498. =head2 3.3 Can I access Microsoft Access or SQL-Server databases with DBI?
  499.  
  500.     Contributed by Tim Bunce and Jeff Urlwin
  501.  
  502. Supplied with DBI-0.79 ( and later ) is an experimental DBI 'emulation layer'
  503. for the I<Win32::ODBC> module. It's called I<DBI::W32ODBC> and is,
  504. at the moment, very minimal. You will need the I<Win32::ODBC> module 
  505. available from:
  506.  
  507.     http://www.roth.net
  508.  
  509. Given its status, problem reports without fixes are likely to be ignored. 
  510. You will also need the I<Win32 DBI patch kit> as supplied by Jeff Urlwin,
  511. which you can locate by reading the previous question's answer.
  512.  
  513. To get back to the question, theoretically, yes, you can access Microsoft 
  514. Access and SQL-Server databases from DBI I<via> ODBC!
  515.  
  516. =head2 3.4 Is the a DBD for <I<insert favourite database here>>?
  517.  
  518. Is is listed on the DBI drivers page?
  519.  
  520.     http://www.hermetica.com/technologia/perl/DBI/DBD
  521.  
  522. If not, no. A complete absence of a given database driver from that
  523. page means that no-one has announced any intention to work on it.
  524.  
  525. A corollary of the above statement implies that if you see an announcement
  526. for a driver I<not> on the above page, there's a good chance it's not
  527. actually a I<DBI> driver, and may not conform to the specifications. Therefore,
  528. questions concerning problems with that code should I<not> really be addressed
  529. to the DBI Mailing Lists.
  530.  
  531. =head2 3.5 What's DBM? And why should I use DBI instead?
  532.  
  533. Extracted from ``I<DBI - The Database Interface for Perl 5>'':
  534.  
  535.     ``UNIX was originally blessed with simple file-based ``databases'', namely
  536.     the dbm system. dbm lets you store data in files, and retrieve
  537.     that data quickly. However, it also has serious drawbacks.
  538.  
  539.         File Locking
  540.  
  541.         The dbm systems did not allow particularly robust file locking
  542.         capabilities, nor any capability for correcting problems arising through
  543.         simultaneous writes [ to the database ].
  544.  
  545.         Arbitrary Data Structures
  546.  
  547.         The dbm systems only allows a single fixed data structure:
  548.         key-value pairs. That value could be a complex object, such as a
  549.         [ C ] struct, but the key had to be unique. This was a large
  550.         limitation on the usefulness of dbm systems.
  551.  
  552.     However, dbm systems still provide a useful function for users with
  553.     simple datasets and limited resources, since they are fast, robust and 
  554.     extremely well-tested. Perl modules to access dbm systems have now
  555.     been integrated into the core Perl distribution via the
  556.     AnyDBM_File module.''
  557.  
  558. To sum up, DBM is a perfectly satisfactory solution for essentially read-only
  559. databases, or small and simple datasets with a single user. However,
  560. for more powerful and scaleable datasets, not to mention robust
  561. transactional locking, users are recommended to use I<DBI>.
  562.  
  563. =head2 3.6 When will mSQL-2 be supported?
  564.  
  565. As of I<DBD::mSQL-0.61>, there has been support for I<mSQL-2>.
  566. However, there is no real support for any of the new methods added to the
  567. core mSQL library regarding index support yet. These are forthcoming
  568. and will be accessible I<via> C<func()> methods private to I<DBD::mSQL>.
  569. You can read more about these private methods in the I<DBD::mSQL> POD
  570. that can be found by typing:
  571.  
  572.     perldoc DBD::mSQL
  573.  
  574. provided you have I<DBD::mSQL> correctly installed.
  575.  
  576. =head2 3.7 What database do you recommend me using?
  577.  
  578. This is a particularly thorny area in which an objective answer is difficult
  579. to come by, since each dataset, proposed usage and system configuration
  580. differs from person to person.
  581.  
  582. From the current author's point of view, if the dataset is relatively
  583. small, being tables of less than 1 million rows, and less than 1000 tables
  584. in a given database, then I<mSQL> is a perfectly acceptable solution
  585. to your problem. This database is extremely cheap, is wonderfully robust
  586. and has excellent support. More information is available on the Hughes
  587. Technology WWW site at:
  588.  
  589.     http://www.hughes.com.au
  590.  
  591. If the dataset is larger than 1 million row tables or 1000 tables, or if you
  592. have either more money, or larger machines, I would recommend the I<Oracle RDBMS>.
  593. Oracle's WWW site is an excellent source of more information.
  594.  
  595.     http://www.oracle.com
  596.  
  597. I<Informix> is another high-end RDBMS that is worth considering. There are
  598. several differences between Oracle and Informix which are too complex for
  599. this document to detail. Information on Informix can be found on their
  600. WWW site at:
  601.  
  602.     http://www.informix.com
  603.  
  604. In the case of WWW fronted applications, I<mSQL> may be a better option
  605. due to slow connection times between a CGI script and the Oracle RDBMS and
  606. also the amount of resource each Oracle connection will consume. I<mSQL>
  607. is lighter resource-wise and faster.
  608.  
  609. These views are not necessarily representative of anyone else's opinions,
  610. and do not reflect any corporate sponsorship or views. They are provided
  611. I<as-is>.
  612.  
  613. =head2 3.8 Is <I<insert feature here>> supported in DBI?
  614.  
  615. Given that we're making the assumption that the feature you have requested
  616. is a non-standard database-specific feature, then the answer will be I<no>.
  617.  
  618. DBI reflects a I<generic> API that will work for most databases, and has
  619. no database-specific functionality defined.
  620.  
  621. However, driver authors may, if they so desire, include hooks to database-specific
  622. functionality through the C<func()> method defined in the DBI API.
  623. Script developers should note that use of functionality provided I<via>
  624. the C<func()> methods is unlikely to be portable across databases.
  625.  
  626. =head1 Programming Questions
  627.  
  628. =head2 4.1 Is DBI any use for CGI programming?
  629.  
  630. In a word, yes! DBI is hugely useful for CGI programming! In fact, I would
  631. tentatively say that CGI programming is one of two top uses for DBI.
  632.  
  633. DBI confers the ability to CGI programmers to power WWW-fronted databases
  634. to their users, which provides users with vast quantities of ordered
  635. data to play with. DBI also provides the possibility that, if a site is
  636. receiving far too much traffic than their database server can cope with, they
  637. can upgrade the database server behind the scenes with no alterations to
  638. the CGI scripts.
  639.  
  640. =head2 4.2 How do I get faster connection times with DBD::Oracle and CGI?
  641.  
  642.     Contributed by John D. Groenveld
  643.  
  644. The Apache C<httpd> maintains a pool of C<httpd> children to service client 
  645. requests.
  646.  
  647. Using the Apache I<mod_perl> module by I<Doug MacEachern>, the perl 
  648. interpreter is embedded with the C<httpd> children. The CGI, DBI, and your 
  649. other favorite modules can be loaded at the startup of each child. These 
  650. modules will not be reloaded unless changed on disk.
  651.  
  652. For more information on Apache, see the Apache Project's WWW site:
  653.  
  654.     http://www.apache.org
  655.  
  656. The I<mod_perl> module can be downloaded from CPAN I<via>:
  657.  
  658.     http://www.perl.com/cgi-bin/cpan_mod?module=mod_perl
  659.  
  660. =head2 4.3 How do I get persistent connections with DBI and CGI?
  661.  
  662.     Contributed by John D. Groenveld
  663.  
  664. Using Edmund Mergl's I<Apache::DBI> module, database logins are stored in a 
  665. hash with each of these C<httpd> child. If your application is based on a 
  666. single database user, this connection can be started with each child. 
  667. Currently, database connections cannot be shared between C<httpd> children.
  668.  
  669. I<Apache::DBI> can be downloaded from CPAN I<via>:
  670.  
  671.     http://www.perl.com/cgi-bin/cpan_mod?module=Apache::DBI
  672.  
  673. =head2 4.4 ``My perl script runs from the command line, but fails under the C<httpd>!'' Why?
  674.  
  675. Basically, a good chance this is occurring is due to the fact that the user
  676. that you ran it from the command line as has a correctly configured set of
  677. environment variables, in the case of I<DBD::Oracle>, variables like
  678. C<$ORACLE_HOME>, C<$ORACLE_SID> or C<TWO_TASK>.
  679.  
  680. The C<httpd> process usually runs under the user id of C<nobody>,
  681. which implies there is no configured environment. Any scripts attempting to
  682. execute in this situation will correctly fail.
  683.  
  684. To solve this problem, set the environment for your database in a C<BEGIN { }>
  685. block at the top of your script. This will generally solve the problem.
  686.  
  687. Similarly, you should check your C<httpd> error logfile for any clues, as
  688. well as the very valuable ``Idiot's Guide To Solving Perl / CGI Problems''
  689. and ``Perl CGI Programming FAQ'' for further information. It is
  690. unlikely the problem is DBI-related.
  691.  
  692. The ``Idiot's Guide To Solving Perl / CGI Problems'' can be located at:
  693.  
  694.     http://www.perl.com/perl/faq/index.html
  695.  
  696. as can the ``Perl CGI Programming FAQ''. Read I<BOTH> these documents 
  697. carefully! They will probably save you many hours of work.
  698.  
  699. =head2 5.1 Can I do multi-threading with DBI?
  700.  
  701. As of the current date of this FAQ ( I<see top of page> ), no. perl
  702. does not support multi-threading. However, multi-threading is expected to
  703. become part of the perl core distribution as of version 5.005, which implies
  704. that DBI may support multi-threading fairly soon afterwards.
  705.  
  706. For some OCI example code for Oracle that has multi-threaded C<SELECT>
  707. statements, see:
  708.  
  709.     http://www.hermetica.com/technologia/oracle/oci/orathreads.tar.gz
  710.  
  711. =head2 5.2 How do I handle BLOB data with DBI?
  712.  
  713. To be written.
  714.  
  715. =head2 5.3 How can I invoke stored procedures with DBI?
  716.  
  717. There is currently no standard way to call stored procedures with DBI.
  718. However, if the database lets you use SQL to call stored procedures
  719. then the DBI and DBD driver probably will to.
  720.  
  721. For example, assuming that you have created a stored procedure within
  722. an Oracle database, you can use C<$dbh>->C<do()> to immediately execute
  723. the procedure:
  724.  
  725.     $dbh->do( "BEGIN someProcedure END;" );    # Oracle specific
  726.  
  727. =head2 5.4 How can I get return values from stored procedures with DBI?
  728.  
  729.     Note: This is Oracle specific. Contributed by Jeff Urlwin
  730.  
  731.     $sth = $dbh->prepare( "BEGIN foo(:1, :2, :3); END;" )  # Oracle specific
  732.                || die $sth->errstr;
  733.     $sth->bind_param(1, $a) || die $sth->errstr;
  734.     $sth->bind_param_inout(2, \$path, 2000)    || die $sth->errstr;
  735.     $sth->bind_param_inout(3, \$success, 2000) || die $sth->errstr;
  736.     $sth->execute || die $sth->errstr;
  737.  
  738. Note the error checking, it may seem like extra work but it'll probably save
  739. you hours in the long run. See $sth->{RaiseError} and $sth->{printError}
  740. in the DBI docs for easier ways to get the same effect.
  741.  
  742. =head2 5.5 How can I create or drop a database with DBI?
  743.  
  744. Database creation and deletion are concepts that are too abstract
  745. to be adequately supported by DBI. For example, Oracle does not support the
  746. concept of dropping a database at all! Also, in Oracle, the database
  747. I<server> essentially I<is> the database, whereas in mSQL, the
  748. server process runs happily without any databases created in it. The
  749. problem is too disparate to attack easily.
  750.  
  751. Some drivers, therefore, support database creation and deletion through
  752. the private C<func()> methods. You should check the documentation for
  753. the drivers you are using to see if they support this mechanism.
  754.  
  755. =head2 5.6 How can I C<commit> or C<rollback> a statement with DBI?
  756.  
  757. To be written. See the C<commit> or C<rollback> methods in the DBI docs.
  758.  
  759. =head2 5.7 How are C<NULL> values handled by DBI?
  760.  
  761. C<NULL> values in DBI are specified to be treated as the value C<undef>.
  762. C<NULL>s can be inserted into databases as C<NULL>, for example:
  763.  
  764.     $rv = $dbh->do( "INSERT INTO table VALUES( NULL )" );
  765.  
  766. but when queried back, the C<NULL>s should be tested against C<undef>.
  767. This is standard across all drivers.
  768.  
  769. =head2 5.8 What are these C<func()> methods all about?
  770.  
  771. The C<func()> method is defined within DBI as being an entry point
  772. for database-specific functionality, I<eg>, the ability to create or
  773. drop databases. Invoking these driver-specific methods is simple, for example,
  774. to invoke a C<createDatabase> method that has one argument, we would
  775. write:
  776.  
  777.     $rv = $dbh->func( 'argument', 'createDatabase' );
  778.  
  779. Software developers should note that the C<func()> methods are
  780. non-portable between databases.
  781.  
  782. =head1 Support and Training
  783.  
  784. The Perl5 Database Interface is I<FREE> software. IT COMES WITHOUT WARRANTY
  785. OF ANY KIND. See the DBI README and DBI documentation for more details.
  786.  
  787. However, some organizations are providing either technical support or
  788. training programs on DBI. The present author has no knowledge as
  789. to the quality of these services. The links are included for reference
  790. purposes only.
  791.  
  792. =head2 Commercial Support
  793.  
  794. =over 4
  795.  
  796. =item The Perl Clinic
  797.  
  798. The Perl Clinic can arrange commercial support contracts for I<Perl>, I<DBI>,
  799. I<DBD::Oracle> and I<Oraperl>. Support is provided by the company with whom
  800. Tim Bunce, author of DBI and DBD::Oracle, works. For more information
  801. on their services, please see:
  802.  
  803.     http://www.perl.co.uk/tpc
  804.  
  805. for more details.
  806.  
  807. =back
  808.  
  809. =head2 Training
  810.  
  811. No training programs are known at this time.
  812.  
  813. =head1 Other References
  814.  
  815. In this section, we present some miscellaneous WWW links that may be of
  816. some interest to DBI users. These are not verified and may result in
  817. unknown sites or missing documents.
  818.  
  819.     http://www-ccs.cs.umass.edu/db.html
  820.     http://www.odmg.org/odmg93/updates_dbarry.html
  821.     http://www.jcc.com/sql_stnd.html
  822.  
  823. =head1 AUTHOR
  824.  
  825. Alligator Descartes <I<descarte@hermetica.com>>
  826.  
  827. =head1 COPYRIGHT
  828.  
  829. This document is Copyright (c)1994-1997 Alligator Descartes, with portions
  830. Copyright (c)1994-1997 their original authors. This module is released under
  831. the 'Artistic' license which you can find in the perl distribution.
  832.  
  833. This document is Copyright (c)1997 Alligator Descartes. All rights reserved.
  834. Permission to distribute this document, in full or in part, via email,
  835. Usenet, ftp archives or http is granted providing that no charges are involved,
  836. reasonable attempt is made to use the most current version and all credits
  837. and copyright notices are retained ( the I<AUTHOR> and I<COPYRIGHT> sections ).
  838. Requests for other distribution rights, including incorporation into 
  839. commercial products, such as books, magazine articles or CD-ROMs should be
  840. made to Alligator Descartes <I<descarte@hermetica.com>>.
  841.  
  842. =for html
  843. <!-- Footer -->
  844. <P>
  845. <HR>
  846. <CENTER>
  847. <FONT SIZE="-1">
  848. <I>
  849. <B>© 1995-97 Hermetica</B><BR>
  850. <A HREF="/descarte/index.html">Alligator Descartes - Hermetica</A>
  851. </I>
  852. </FONT>
  853. </CENTER>
  854. </BODY>
  855. </HTML>
  856.